* STATA Do file for Chapter 2, Mark R. Beissinger, The Revolutionary City  
version 14
clear all
set more off
log using Logfiles\chapter2.log, replace
* ======================================================================
* STATISTICAL RESULTS APPEARING IN CHAPTER 2, THE REVOLUTIONARY CITY
* Results reported in Chapter 2 
* Author: Mark R. Beissinger  
* Date:  January 2022  
* Princeton, NJ 
* ======================================================================
* BEFORE RUNNING, YOU MUST SET THE DEFAULT PATH FOR WHERE THE DATA
*   FILES RESIDE
* ======================================================================
* The following datafiles were used in this chapter:
*   Monitoring surveys (Ukraine)--monitoring20052014engmerged.dta
*   2011 Arab Barometer--Tunisia and Egypt--fullarabbarom2.dta
*   States and episodes--statesandepisodes.dta 
*   Risk of revolutionary episodes--revspellsbase.dta
*   Panel data for revolutionary episodes--revspredictbycntryyr.dta
*   Data set of revolutionary episodes--revolutionaryeps.dta
*   Data set of demonstrations in USSR during glasnost'--glasnostdemonstrations.dta
*   World Survey Wave 6 (recoded by author for analysis)--worldvalues.wave6.2010-14.dta
* =====================================================================
* Before running, you must ensure that the following STATA package is installed:
*   arpois from http://www.stata.com/stb/stb46
* =====================================================================
* Output produced:  Logfiles\chapter2.log
*					Logfiles\figure2_4.pdf
* =====================================================================

* ====================================================
* OVERALL TEMPORAL PATTERNS OF REVOLUTIONARY EPISODES
* ====================================================
use statesandepisodes.dta 
arpois newrevs1000  postcoldwar , ar(2) delete 
arpois nocommnewrevs1000  postcoldwar , ar(2) delete 
arpois ongoing1000 coldwar postcoldwar , ar(1) delete 
arpois nocommongoing1000 coldwar postcoldwar , ar(1) delete 

* ===================================================================
* EFFECT OF STATE INDEPENDENCE ON OUTBREAK OF REVOLUTIONARY EPISODES
* ===================================================================
use "revspredictbycntryyr.dta", clear
xtcloglog revny c.lnyrsindependent##c.lnyrsindependent time1 timesq timecub if year<1985, vce(robust) nolog eform
margins, atmeans at(lnyrsindependent=(0 .69314718 1.0986123 1.3862944 1.6094379 1.7917595 1.9459101 2.0794415 2.1972246 2.3025851))
xtcloglog revny c.lnyrsindependent##c.lnyrsindependent time1 timesq timecub if year>1984, vce(robust) nolog eform
xtcloglog revny lnyrsindependent time1 timesq timecub if year>1984, vce(robust) nolog eform
xtcloglog ruralrevny lnyrsindependent time1 timesq timecub, vce(robust) nolog eform
xtcloglog urbanrevny lnyrsindependent time1 timesq timecub, vce(robust) nolog eform

* ================================
* NUMBER OF STATES AND REVOLUTION
* ================================
use "statesandepisodes.dta", clear
arpois newrevs1000 statesl , ar(2) delete 
* compute IRR
matrix b = e(b)
scalar X1= b[1,2]
display exp(X1)
scalar drop _all
* Estimated effect on number of revs by early 21st century
predict xb
generate exp_xb = exp(xb)
summarize exp_xb if year>1899 & year<1920
summarize exp_xb if year>1999 & year<2015
drop xb exp_xb

* ==================================
* WORLD URBANIZATION AND REVOLUTION
* ==================================
arpois newrevs1000 estworldurbanl , ar(2) delete
* compute IRR
matrix b = e(b)
scalar X1= b[1,2]
display exp(X1)
scalar drop _all
* Estimated effect on number of revs by early 21st century
predict xb
generate exp_xb = exp(xb)
summarize exp_xb if year>1899 & year<1920
summarize exp_xb if year>1999 & year<2015
drop xb exp_xb

* =======================================================================
* GROWING HAZARD OF REVOLUTIONARY EPISODES ACROSS FIXED TERRITORIAL UNITS
* =======================================================================
clear
use revspellsbase.dta
* Monthly results temporarily stored in hazard.dta
sts graph, hazard width(12) outfile(hazard, replace)
clear
use hazard.dta
generate yrhazard = 12 * Vhazard
twoway (lfitci yrhazard _t) (line yrhazard _t)
* Saving graph to hard drive as figure2.4.pdf
graph export Logfiles\figure2_4.pdf, replace
* Closing graph editor
graph drop _all
erase hazard.dta

* ========================================================================
* ROLE OF URBAN AND URBAN CIVIC REVS IN GROWTH OF REV EPISODES, FIGURE 2.7
* ========================================================================
clear
use statesandepisodes.dta
arpois newrevs1000 year, delete
arpois urbanrevs year, delete
arpois ruralrevs year, delete
arpois noleft year, delete
arpois leftist year, delete
arpois nociv year, delete
arpois urbanciv year, delete

* =====================================================
* LAND CONCENTRATION IN SOCIAL REVOLUTIONS--FIGURE 2.8
* =====================================================
clear
use revspredictbycntryyr.dta
xtcloglog leftistny landgini c.time1##c.time1##c.time1, vce(robust) eform nolog
margins, atmeans at(landgini=(0 10 20 30 40 50 60 70 80 90 100))
* Versus urban, rural, and urban civic revolutions
xtcloglog ruralrevny landgini c.time1##c.time1##c.time1, vce(robust) eform nolog
xtcloglog urbanrevny landgini c.time1##c.time1##c.time1, vce(robust) eform nolog
xtcloglog urbancivicny landgini c.time1##c.time1##c.time1, vce(robust) eform nolog

* ===================================================================
* RAPID POPULATION GROWTH AND YOUTH BULGES IN REVOLUTIONARY EPISODES
* ===================================================================
* Before and after end of Cold War--adults aged 15-24
xtcloglog revny  i.postcoldwar##c.youthpercl time1 timesq timecub, vce(robust) nolog eform
*  Aged 15-24, controlling for population size, level of development, and economic growth
xtcloglog revny lnpopl gdppcthl gdppcgrow1yrl i.postcoldwar##c.youthpercl time1 timesq timecub, vce(robust) nolog eform
*  Youth bulges, as measured by populaton aged 0-15
xtcloglog revny i.postcoldwar##c.percunder15l time1 timesq timecub, vce(robust) nolog eform
*  Aged 0-15, controlling for population size, level of development, and economic growth
xtcloglog revny lnpopl gdppcthl gdppcgrow1yrl i.postcoldwar##c.percunder15l time1 timesq timecub, vce(robust) nolog eform
* Rural vs. urban revs
xtcloglog ruralrevny lnpopl youthpercl time1 timesq timecub, vce(robust) nolog eform
xtcloglog urbanrevny lnpopl youthpercl time1 timesq timecub, vce(robust) nolog eform
* Interaction between economic growth and youth bulges
xtcloglog revny lnpopl gdppcthl c.gdppcgrow1yrl##c.youthpercl time1 timesq timecub, vce(robust) nolog eform
xtcloglog revny lnpopl gdppcthl c.gdppcgrow1yrl##c.percunder15l time1 timesq timecub, vce(robust) nolog eform

* ========================================================
* URBANIZATION AND THE LOCATION OF REVOLUTIONARY EPISODES
* ========================================================
clear
use revolutionaryeps.dta
ttest urbpercbefrev, by(urbandum)

* ========================================================================
* URBANIZATION MAKING URBAN REVOLTS MORE LIKELY, RURAL REVOLTS LESS LIKELY
* ========================================================================
clear
use revspredictbycntryyr.dta
xtcloglog urbanrevny lnpopl gdppcthl  polityl polityl2 percurbanl time1 timesq timecub, vce(robust) nolog eform
xtcloglog ruralrevny lnpopl gdppcthl  polityl polityl2 percurbanl time1 timesq timecub, vce(robust) nolog eform

* =========================================================
* HIGHER EDUCATION AND OCCUPATION IN THE ORANGE REVOLUTION
* =========================================================
clear
use monitoring20052014engmerged.dta
logit newpartica age gender highered if EVA_vers=="yr2005", or nolog
margins, atmeans at(highered=(0 1))
clear
use monitoring20052014engmerged.dta
logit newpartica age gender middleclass student worker skilledworker business farmworker unemployed if EVA_vers=="yr2005", or nolog

* =========================================================================
* HIGHER EDUCATION AND OCCUPATION IN THE TUNISIAN AND EGYPTIAN REVOLUTIONS
* =========================================================================
clear
use fullarabbarom2.dta
logit participate gender q1001 highered if counu==11, or nolog
margins, atmeans at(highered=(0 1))
logit participate gender q1001 professional worker farmer mgmt employee student unemployed if counu==11, or nolog
logit participate gender q1001 highered if counu==7, or nolog
margins, atmeans at(highered=(0 1))
logit participate gender q1001 professional worker farmer mgmt employee student unemployed if counu==7, or nolog

* ======================================================================
* EFFECT OF NUMBER OF PARTICIPANTS ON REPRESSION IN USSR UNDER GLASNOST'
* ======================================================================
clear
use glasnostdemonstrations.dta, clear
logit repressdum partic [fweight=duration], or nolog
margins, at(partic=(100 500 1000 3000 5000 7000 10000 25000 50000 100000 200000 300000 400000))

* =======================================================================
* USE OF MASS MEDIA IN REVOLUTIONARY EPISODES IN RURAL AND URBAN SETTINGS
* =======================================================================
clear
use revolutionaryeps.dta
logit nomedia startyear urbandum if startyear>1899, or nolog
margins, atmeans at(urbandum=(0 1))
logit newspaperused startyear urbandum, or nolog
margins, atmeans at(urbandum=(0 1))
logit radioused startyear urbandum if startyear>1929, or nolog
margins, atmeans at(urbandum=(0 1))
logit televisused startyear urbandum if startyear>1964, or nolog
margins, atmeans at(urbandum=(0 1))
logit socialmediaused startyear urbandum if startyear>1989, or nolog
margins, atmeans at(urbandum=(0 1))

* ======================================
* VARIOUS T-TESTS AND OTHER TESTS CITED
* ======================================
clear
use revolutionaryeps.dta
ttest urbpercbefrev if startyear>1899, by(urbandum)
ttest litpercbefrev if startyear>1899, by(urbandum)
ttest newspercap if startyear>1964, by(urbandum)
ttest radiospercap if startyear>1929, by(urbandum)
ttest televispercap if startyear>1899, by(urbandum)
ttest newinternetuse if startyear>1989, by(urbandum)
tab urbandum revwaveny, row chi
ttest mtnest if startyear>1899, by(urbandum)
ttest politymin1 if startyear>1899, by(urbandum)
ttest politymin1 if startyear>1899 & (urbancivic==1 | leftist==1), by(urbancivic)
ttest incumbpowerdur if startyear>1899, by(urbandum)
ttest incumbpowerdur if startyear>1899 & (leftist==1 | urbancivic==1), by(urbancivic)
ttest vdpolcorrmin1 if startyear>1899, by(urbandum)
ttest vdpolcorrmin1 if startyear>1899 & (urbancivic==1 | leftist==1), by(urbancivic)
ttest statecapacity if startyear>1899, by(urbandum)
ttest statecapacity=0 if startyear>1899 & urbandum==0
ttest statecapacity=0 if startyear>1899 & leftist==1
ttest statecapacity=0 if startyear>1899 & urbandum==1
ttest statecapacity if startyear>1899 & urbandum==0, by(success)
ttest statecapacity if startyear>1899 & urbancivic==1, by(success)

* ======================
* POLITICAL OPPORTUNITY
* ======================
tab urbandum polopportunity if startyear>1899, row chi
tab urbancivic polopportunity if startyear>1899, row chi
tab urbancivic success if startyear>1899 & polopportunity==1, row chi
tab urbandum success if startyear>1899 & polopportunity==1, row chi

* =======================================
* RELATIONSHIP OF URBAN/RURAL TO TIME SINCE INDEPENDENCE
* =======================================
clear
use revspredictbycntryyr.dta
xtcloglog ruralrevny lnyrsindependent time1 timesq timecub, nolog eform vce(robust)
xtcloglog urbanrevny lnyrsindependent time1 timesq timecub, nolog eform vce(robust)

* =======================================================
* RELATIONSHIP TO EFFECTIVE TERRITORIAL CONTROL OF STATES
* =======================================================
xtcloglog ruralrevny v2svstterr time1 timesq timecub, nolog eform vce(robust)
xtcloglog urbanrevny v2svstterr time1 timesq timecub, nolog eform vce(robust)

* ==============================================================
* COUNTRY EXTERNAL BATTLE DEATHS AND ONSET OF SOCIAL REVOLUTIONS
* ==============================================================
xtcloglog leftistny lnextwardeathsl time1 timesq timecub if colony==0, vce(robust) eform nolog
xtcloglog antimonarchny lnextwardeathsl time1 timesq timecub if colony==0, vce(robust) eform nolog
xtcloglog urbancivicny lnextwardeathsl time1 timesq timecub if colony==0, vce(robust) eform nolog
xtcloglog independny lnextwardeathsl  time1 timesq timecub , vce(robust) eform nolog
xtcloglog ethnicorderny lnextwardeathsl time1 timesq timecub if colony==0, vce(robust) eform nolog

* ================================================================
* FINANCIAL CRISIS AND ONSET OF URBAN CIVIC AND SOCIAL REVOLUTIONS
* ================================================================
xtcloglog urbancivicny rrfinstressl time1 timesq timecub if colony==0, vce(robust) eform nolog

* ======================================================================
* DIFFUSION OF REVOLUTION AND URBAN/URBAN CIVIC REVOLUTIONARY CONTENTION
* ======================================================================
clear
use revolutionaryeps.dta
logit revwaveny urbandum startyear if startyear>1899, or
margins, at(urbandum=(0 1))
logit revwaveny urbancivic startyear if startyear>1899, or
margins, at(urbancivic=(0 1))

log close

clear
